import axios, {AxiosInstance, AxiosRequestConfig} from "axios";

const service: AxiosInstance = axios.create({
  // baseURL: process.env.NODE_ENV == "development" ? "/api" : "http://110.42.204.136:8081",
  baseURL: "/api",
  timeout: 10000,
  timeoutErrorMessage: "连接超时"
});


service.interceptors.request.use(
  (config: AxiosRequestConfig) => {
    // 不通过token判断登录
    /*const token: string | undefined = store.getters.token || Cache.getToken();
    if (token) {
      config.headers["X-Token"] = token;
    }*/
    return config;
  },
  (error: any) => {
    return Promise.reject(error);
  }
);

service.interceptors.response.use(
  (res: any) => {
    return res.data;
  },
  (error: any) => {
    return Promise.reject(error);
  }
);

export default service;
